package com.heima.api.client;

import com.heima.api.config.DefaultFeignConfig;
import com.heima.api.domain.dto.ItemDTO;
import com.heima.api.domain.dto.OrderDetailDTO;
import com.heima.api.fallback.ItemClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

// value值对应服务在注册中心的名称
@FeignClient(value = "item-service"
        ,configuration = DefaultFeignConfig.class
        ,fallbackFactory =  ItemClientFallback.class) //fallbackFactory
public interface ItemClient {
    @GetMapping("/items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids") List<Long> ids);


    @PutMapping("/items/stock/deduct")
    void deductStock(@RequestBody List<OrderDetailDTO> items);
}
